<script setup name="Child" lang="ts">
interface IProps {
  money: number
  car?: string
}
const { car = '三轮车' } = defineProps<IProps>()
// 需求：点击按钮修改父亲的 money 和 car

// const emits = defineEmits(['changeMoney', 'changeCar'])

const emits = defineEmits<{
  // evName 表示自定义事件的名字
  // m 表示当我触发 evName 的时候传递的参数的类型
  (evName: 'changeMoney', m: number): void
  (evName: 'changeCar', c: string): void
}>()
</script>
<template>
  <div>
    <p>
      money: {{ money }}
      <button @click="emits('changeMoney', 1)">update money</button>
    </p>
    <p>
      car: {{ car }}
      <button @click="emits('changeCar', '奔驰')">update car</button>
    </p>
  </div>
</template>
